# v850 bsh
# mach: v850e
# as(v850e): -mv850e

	.include "testutils.inc"

	seti	0x12345678, r1
	bsh	r1, r2

	flags	0
	reg	r2, 0x34127856

# CY is 1 if one or more bytes in the result half-word is zero, else 0

	seti	0x12345600, r1
	bsh	r1, r2
	flags	c
	reg	r2, 0x34120056

	seti	0x12340078, r1
	bsh	r1, r2
	flags	c
	reg	r2, 0x34127800

	seti	0x12005678, r1
	bsh	r1, r2
	flags	0
	reg	r2, 0x00127856

	seti	0x00345678, r1
	bsh	r1, r2
	flags	0
	reg	r2, 0x34007856

# S is set if the result is negative

	seti	0x00800000, r1
	bsh	r1, r2
	flags	s + c + z
	reg	r2, 0x80000000

# Z is set if the result is zero
# According to NEC, the Z flag depends on only the lower half-word

	seti	0x00000000, r1
	bsh	r1, r2
	flags	c + z
	reg	r2, 0x00000000

	seti	0xffff0000, r1
	bsh	r1, r2
	flags	c + s + z
	reg	r2, 0xffff0000

	pass
